<?php
/**
 * Author: 式神(vashi)
 * email: 289650682@qq.com
 * Date: 2019/2/20 10:12
 * FileName: AdsData.php
 */

namespace app\cms\model;

class AdsData extends Common
{
    protected $tip_name = '广告';
    protected $validate;
    protected $table;

    public function initialize()
    {
        parent::initialize();
        $this->validate = new \app\cms\validate\AdsData();
    }

    //添加内容
    public function add($input){
        if(!isset($input['start_time']) || !$input['start_time']){
            $today = request()->time();
            $input['start_time']=$today;
        }else{
            $today = strtotime($input['start_time']);
            $input['start_time']=$today;
        }
        if(!isset($input['end_time']) || !$input['end_time']){
            $today = end_day(request()->time());
            $input['end_time']=$today;
        }else{
            $today = strtotime($input['end_time']);
            $input['end_time']=$today;
        }
        return $this->addModel($input);
    }

    //编辑内容
    public function edit($input){
        if(!isset($input['start_time']) || !$input['start_time']){
            $today = request()->time();
            $input['start_time']=$today;
        }else{
            $today = strtotime($input['start_time']);
            $input['start_time']=$today;
        }
        if(!isset($input['end_time']) || !$input['end_time']){
            $today = end_day(request()->time());
            $input['end_time']=$today;
        }else{
            $today = strtotime($input['end_time']);
            $input['end_time']=$today;
        }
        return $this->editModel($input);
    }

    public function del($input){
        $res = $this->delModel($input);
        return $res;
    }
}